﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace H2.NET.Web.Pages.SMD.Dto
{
    public class ContractDto
    {
        public int ContractID { get; set; }
        public int StoreID { get; set; }
        public string AuthID { get; set; }
        public string StoreContractSN { get; set; }
        public decimal? StoreDeposit { get; set; }
        public string StoreContractType { get; set; }
        public DateTime? StoreContractBeginDate { get; set; }
        public DateTime? StoreContractEndDate { get; set; }
        public Boolean HasAwardContract { get; set; }
        public DateTime? AwardContractBeginDate { get; set; }
        public DateTime? AwardContractEndDate { get; set; }
        public Boolean HasTransferContract { get; set; }
        public string TransferFromStoreSN { get; set; }
        public string TransferToStoreSN { get; set; }
        public DateTime? TransferContractDate { get; set; }
        public Boolean HasRenewContract { get; set; }
        public DateTime? RenewContractBeginDate { get; set; }
        public DateTime? RenewContractEndDate { get; set; }
        public bool? SubmitToFinancial { get; set; }
        public string ContractArchive { get; set; }
        public string Remark { get; set; }
        public string StoreNature { get; set; }
        public string StoreAffiliation { get; set; }
        public string StoreStamp { get; set; }
        public string StoreParty { get; set; }
        public int StoreCopies { get; set; }
        public DateTime? StoreExpressDate { get; set; }
        public string StoreEms { get; set; }
        public string ToStoreEms { get; set; }
        public Boolean StoreFinance { get; set; }
        public string StoreArchive { get; set; }
        public string StoreFileNO { get; set; }
        public string StoreNotSignReason { get; set; }
        public List<ContractDeviceDto> devices { get;set; }
        public static List<ContractDto> HB(List<ContractDto> stores, List<ContractDto> devices)
        {
            List<ContractDto> contractDtos = new List<ContractDto>();
            foreach (var store in stores)
            {
                ContractDto contractDto = new ContractDto();
                if (devices != null && devices.Count() > 0)
                {
                    foreach (var device in devices)
                    {
                        if (store.ContractID == device.ContractID) 
                        {
                            contractDto.ContractID = store.ContractID;
                            contractDto.StoreID = store.StoreID;
                            contractDto.AuthID = store.AuthID;
                            contractDto.StoreContractSN = store.StoreContractSN;
                            contractDto.StoreDeposit = store.StoreDeposit;
                            contractDto.StoreContractType = store.StoreContractType;
                            contractDto.StoreContractBeginDate = store.StoreContractBeginDate;
                            contractDto.StoreContractEndDate = store.StoreContractEndDate;
                            contractDto.HasAwardContract = store.HasAwardContract;
                            contractDto.AwardContractBeginDate = store.AwardContractBeginDate;
                            contractDto.AwardContractEndDate = store.AwardContractEndDate;
                            contractDto.HasTransferContract = store.HasTransferContract;
                            contractDto.TransferFromStoreSN = store.TransferFromStoreSN;
                            contractDto.TransferToStoreSN = store.TransferToStoreSN;
                            contractDto.TransferContractDate = store.TransferContractDate;
                            contractDto.HasRenewContract = store.HasRenewContract;
                            contractDto.RenewContractBeginDate = store.RenewContractBeginDate;
                            contractDto.RenewContractEndDate = store.RenewContractEndDate;
                            contractDto.SubmitToFinancial = store.SubmitToFinancial;
                            contractDto.ContractArchive = store.ContractArchive;
                            contractDto.Remark = store.Remark;
                            contractDto.StoreNature = store.StoreNature;
                            contractDto.StoreAffiliation = store.StoreAffiliation;
                            contractDto.StoreStamp = store.StoreStamp;
                            contractDto.StoreParty = store.StoreParty;
                            contractDto.StoreCopies = store.StoreCopies;
                            contractDto.StoreExpressDate = store.StoreExpressDate;
                            contractDto.StoreEms = store.StoreEms;
                            contractDto.ToStoreEms = store.ToStoreEms;
                            contractDto.StoreFinance = store.StoreFinance;
                            contractDto.StoreArchive = store.StoreArchive;
                            //contractDto.ContractDeviceID = device.ContractDeviceID;
                            //contractDto.ContractID = device.ContractID;
                            //contractDto.DeviceNature = device.DeviceNature;
                            //contractDto.DeviceAffiliation = device.DeviceAffiliation;
                            //contractDto.DeviceStamp = device.DeviceStamp;
                            //contractDto.DeviceParty = device.DeviceParty;
                            //contractDto.DeviceCopies = device.DeviceCopies;
                            //contractDto.DeviceExpressDate = device.DeviceExpressDate;
                            //contractDto.DeviceEms = device.DeviceEms;
                            //contractDto.ToDeviceEms = device.ToDeviceEms;
                            //contractDto.DeviceFinance = device.DeviceFinance;
                            //contractDto.DeviceArchive = device.DeviceArchive;
                            //contractDto.DeviceRemark = device.DeviceRemark;
                            //contractDto.DeviceFixAssetNo = device.DeviceFixAssetNo;
                            //contractDto.DeviceConractSN = device.DeviceConractSN;
                            //contractDto.DeviceDeposit = device.DeviceDeposit;
                            //contractDto.DeviceConractType = device.DeviceConractType;
                            //contractDto.DeviceContractBeginDate = device.DeviceContractBeginDate;
                            //contractDto.DeviceContractEndDate = device.DeviceContractEndDate;
                            //contractDto.DeliveryNo = device.DeliveryNo;
                            //contractDto.DeliveryDate = device.DeliveryDate;
                            break;
                        }
                        else
                        {
                            contractDto = store;
                        }
                    }
                }
               
            
                contractDtos.Add(contractDto);
            }


            return contractDtos;
        }
        public ContractCancelDto StoreCancel { get; set; }
        public string StoreType { get; set; }

    }
}